<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>C Miniglk</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Extracts-Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'C Miniglk' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../intern.html">Inter Modules</a></li><li><a href="index.html">final</a></li><li><a href="index.html#5">Chapter 5: C</a></li><li><b>C Miniglk</b></li></ul></div>
<p class="purpose">Just enough of the Glk input/output interface to allow simple console text in and out, and no more.</p>

<ul class="toc"><li><a href="5-cmn.html#SP1">&#167;1. Glk - an apology</a></li><li><a href="5-cmn.html#SP2">&#167;2. The Glk handler</a></li><li><a href="5-cmn.html#SP3">&#167;3. Gestalt</a></li><li><a href="5-cmn.html#SP4">&#167;4. Characters</a></li><li><a href="5-cmn.html#SP5">&#167;5. Miniglk data</a></li><li><a href="5-cmn.html#SP7">&#167;7. File-handling</a></li><li><a href="5-cmn.html#SP9">&#167;9. Streams</a></li><li><a href="5-cmn.html#SP16">&#167;16. Windows</a></li><li><a href="5-cmn.html#SP17">&#167;17. Events</a></li><li><a href="5-cmn.html#SP20">&#167;20. Styling</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Glk - an apology.</b>The code below is in no way a proper implementation of the Glk input/output
system, which was developed as an interactive fiction standard by Andrew Plotkin,
and which has served us well and will continue to do so. It is not even a full
implementation of basic console I/O via Glk, for which see the <span class="extract"><span class="extract-syntax">cheapglk</span></span>
C library.
</p>

<p class="commentary">Instead, our aim is to do the absolute minimum possible in simple self-contained
C code, and to impose as few restrictions as possible beyond that. The flip side
of Glk's gilt-edged engineering quality is that it can be a gilded cage: for some
imaginable uses of Inform 7-via-C, say based on Unity or in an iOS app, strict
use of Glk would be constraining.
</p>

<p class="commentary">In an attempt to have the best of both worlds, the code below is only the
default Glk implementation for an Inform 7-via-C project, and the user can
duck out of it by providing an implementation of her own. (Indeed, this could
even be <span class="extract"><span class="extract-syntax">cheapglk</span></span>, as mentioned above.)
</p>

<p class="commentary">This section of code therefore defines just two functions, <span class="extract"><span class="extract-syntax">i7_default_stylist</span></span>
and <span class="extract"><span class="extract-syntax">i7_default_glk</span></span>, plus their supporting code &mdash; which turns out to be quite
a lot, but there are only those two points of entry.
</p>

<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. The Glk handler.</b>The <span class="extract"><span class="extract-syntax">@glk selector varargc s1</span></span> opcode performs some I/O function indexed by the
<span class="extract"><span class="extract-syntax">selector</span></span> value, taking some number of arguments which have been placed on the
stack: <span class="extract"><span class="extract-syntax">varargc</span></span> is the number of these, which may be anything from 0 to 5.
Some functions return a value which is stored in <span class="extract"><span class="extract-syntax">s1</span></span>, others do not; as with
all assembly store operands, though, supplying 0 as the store location causes
no store to take place.
</p>

<p class="commentary">The code below can only be understood with the Glk reference documentation to
hand, and we won't try to duplicate that here.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_default_glk</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">selector</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">varargc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">z</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_debug_stack</span><span class="Extracts-plain-syntax">("</span><span class="Extracts-identifier-syntax">i7_opcode_glk</span><span class="Extracts-plain-syntax">");</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[5] = { </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax"> }, </span><span class="Extracts-identifier-syntax">argc</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">while</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">varargc</span><span class="Extracts-plain-syntax"> &gt; </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">v</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_pull</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">argc</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-constant-syntax">5</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">argc</span><span class="Extracts-plain-syntax">++] = </span><span class="Extracts-identifier-syntax">v</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">varargc</span><span class="Extracts-plain-syntax">--;</span>
<span class="Extracts-plain-syntax">    }</span>

<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">switch</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">selector</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_gestalt</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_miniglk_gestalt</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>

<span class="Extracts-plain-syntax">        /* </span><span class="Extracts-identifier-syntax">Characters</span><span class="Extracts-plain-syntax"> */</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_char_to_lower</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_miniglk_char_to_lower</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_char_to_upper</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_miniglk_char_to_upper</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_buffer_to_lower_case_uni</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">for</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">=0; </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">&lt;</span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[2]; </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">++) {</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_read_word</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0], </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">i7_write_word</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0], </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7_miniglk_char_to_lower</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">));</span>
<span class="Extracts-plain-syntax">            }</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[2]; </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_buffer_canon_normalize_uni</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[2]; </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">; /* </span><span class="Extracts-identifier-syntax">Ignore</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">this</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">one</span><span class="Extracts-plain-syntax"> */</span>

<span class="Extracts-plain-syntax">        /* </span><span class="Extracts-identifier-syntax">File</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">handling</span><span class="Extracts-plain-syntax"> */</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_fileref_create_by_name</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_miniglk_fileref_create_by_name</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[1], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[2]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_fileref_does_file_exist</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_miniglk_fileref_does_file_exist</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        /* </span><span class="Extracts-identifier-syntax">And</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">we</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">ignore</span><span class="Extracts-plain-syntax">: */</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_fileref_destroy</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_fileref_iterate</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>

<span class="Extracts-plain-syntax">        /* </span><span class="Extracts-identifier-syntax">Stream</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">handling</span><span class="Extracts-plain-syntax"> */</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_stream_get_position</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_get_position</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_stream_close</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_close</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[1]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_stream_set_current</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_set_current</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_stream_get_current</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_get_current</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_stream_open_memory</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_open_memory</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[1], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[2], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[3]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_stream_open_memory_uni</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_open_memory_uni</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[1], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[2], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[3]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_stream_open_file</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_open_file</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[1], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[2]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_stream_set_position</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_set_position</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[1], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[2]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_put_char_stream</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">i7_miniglk_put_char_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[1]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_get_char_stream</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_miniglk_get_char_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_put_buffer_uni</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            {</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">str</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_get_current</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">for</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">=0; </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">&lt;</span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[1]; </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">++) {</span>
<span class="Extracts-plain-syntax">                    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_read_word</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0], </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">                    </span><span class="Extracts-identifier-syntax">i7_miniglk_put_char_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">str</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">                }</span>
<span class="Extracts-plain-syntax">            }</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        /* </span><span class="Extracts-identifier-syntax">And</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">we</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">ignore</span><span class="Extracts-plain-syntax">: */</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_stream_iterate</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>

<span class="Extracts-plain-syntax">        /* </span><span class="Extracts-identifier-syntax">Window</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">handling</span><span class="Extracts-plain-syntax"> */</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_window_open</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_miniglk_window_open</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[1], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[2], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[3], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[4]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_set_window</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_miniglk_set_window</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_window_get_rock</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_mg_get_window_rock</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_window_get_size</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_miniglk_window_get_size</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[1], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[2]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        /* </span><span class="Extracts-identifier-syntax">And</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">we</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">ignore</span><span class="Extracts-plain-syntax">: */</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_window_iterate</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_window_move_cursor</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>

<span class="Extracts-plain-syntax">        /* </span><span class="Extracts-identifier-syntax">Event</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">handling</span><span class="Extracts-plain-syntax"> */</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_request_line_event</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_miniglk_request_line_event</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[1], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[2], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[3]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_request_line_event_uni</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_miniglk_request_line_event_uni</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[1], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[2], </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[3]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_select</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_miniglk_select</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a</span><span class="Extracts-plain-syntax">[0]); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>

<span class="Extracts-plain-syntax">        /* </span><span class="Extracts-identifier-syntax">Other</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">selectors</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">we</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">recognise</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">but</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">then</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">ignore</span><span class="Extracts-plain-syntax">: */</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_set_style</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_stylehint_set</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_schannel_create</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_glk_schannel_iterate</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>

<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">default</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">printf</span><span class="Extracts-plain-syntax">("</span><span class="Extracts-identifier-syntax">Unimplemented</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">Glk</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">selector</span><span class="Extracts-plain-syntax">: %</span><span class="Extracts-identifier-syntax">d</span><span class="Extracts-plain-syntax">.\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">", </span><span class="Extracts-identifier-syntax">selector</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">z</span><span class="Extracts-plain-syntax">) *</span><span class="Extracts-identifier-syntax">z</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">rv</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. Gestalt.</b>The following is overdone, really: the standard Inform kits ask only about
<span class="extract"><span class="Extracts-extract-syntax">i7_gestalt_Unicode</span></span>, <span class="extract"><span class="Extracts-extract-syntax">i7_gestalt_Sound</span></span> and <span class="extract"><span class="Extracts-extract-syntax">i7_gestalt_Graphics</span></span>.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_gestalt</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">g</span><span class="Extracts-plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_gestalt</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">g</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">switch</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">g</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_Version</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_CharInput</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_LineInput</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_Unicode</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_UnicodeNorm</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_CharOutput</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_CharOutput_CannotPrint</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_MouseInput</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_Timer</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_Graphics</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_DrawImage</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_Sound</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_SoundVolume</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_SoundNotify</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_Hyperlinks</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_HyperlinkInput</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_SoundMusic</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_GraphicsTransparency</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_LineInputEcho</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_LineTerminators</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_LineTerminatorKey</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_DateTime</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_Sound2</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_ResourceStream</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_gestalt_GraphicsCharInput</span><span class="Extracts-plain-syntax">:</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. Characters.</b>These need only be performed on the ISO Latin-1 range, so are easy.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_char_to_lower</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_char_to_upper</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_char_to_lower</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (((</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">x41</span><span class="Extracts-plain-syntax">) &amp;&amp; (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &lt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">x5A</span><span class="Extracts-plain-syntax">)) ||</span>
<span class="Extracts-plain-syntax">        ((</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">xC0</span><span class="Extracts-plain-syntax">) &amp;&amp; (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &lt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">xD6</span><span class="Extracts-plain-syntax">)) ||</span>
<span class="Extracts-plain-syntax">        ((</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">xD8</span><span class="Extracts-plain-syntax">) &amp;&amp; (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &lt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">xDE</span><span class="Extracts-plain-syntax">))) </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> += </span><span class="Extracts-constant-syntax">32</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_char_to_upper</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (((</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">x61</span><span class="Extracts-plain-syntax">) &amp;&amp; (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &lt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">x7A</span><span class="Extracts-plain-syntax">)) ||</span>
<span class="Extracts-plain-syntax">        ((</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">xE0</span><span class="Extracts-plain-syntax">) &amp;&amp; (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &lt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">xF6</span><span class="Extracts-plain-syntax">)) ||</span>
<span class="Extracts-plain-syntax">        ((</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">xF8</span><span class="Extracts-plain-syntax">) &amp;&amp; (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &lt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">xFE</span><span class="Extracts-plain-syntax">))) </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> -= </span><span class="Extracts-constant-syntax">32</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. Miniglk data.</b>Each process needs to keep track of its own files, streams, windows and events,
which are wrapped up in a <span class="extract"><span class="Extracts-extract-syntax">miniglk_data</span></span> structure as follows:
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-plain-syntax">#</span><span class="Extracts-identifier-syntax">define</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">I7_MINIGLK_LEAFNAME_LENGTH</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">128</span>

<span class="Extracts-identifier-syntax">typedef</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">struct</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_file_t</span><span class="Extracts-plain-syntax"> {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">usage</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">name</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">leafname</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">I7_MINIGLK_LEAFNAME_LENGTH</span><span class="Extracts-plain-syntax"> + </span><span class="Extracts-constant-syntax">32</span><span class="Extracts-plain-syntax">];</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">FILE</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">handle</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">} </span><span class="Extracts-identifier-syntax">i7_mg_file_t</span><span class="Extracts-plain-syntax">;</span>

<span class="Extracts-identifier-syntax">typedef</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">struct</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_stream_t</span><span class="Extracts-plain-syntax"> {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">FILE</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">to_file</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">to_file_id</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">wchar_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">to_memory</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">size_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">memory_used</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">size_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">memory_capacity</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">previous_id</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">write_here_on_closure</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">size_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">write_limit</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">active</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">encode_UTF8</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">char_size</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">chars_read</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">read_position</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">end_position</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">owned_by_window_id</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">fixed_pitch</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">style</span><span class="Extracts-plain-syntax">[128];</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">composite_style</span><span class="Extracts-plain-syntax">[300];</span>
<span class="Extracts-plain-syntax">} </span><span class="Extracts-identifier-syntax">i7_mg_stream_t</span><span class="Extracts-plain-syntax">;</span>

<span class="Extracts-identifier-syntax">typedef</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">struct</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_window_t</span><span class="Extracts-plain-syntax"> {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">type</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">stream_id</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">} </span><span class="Extracts-identifier-syntax">i7_mg_window_t</span><span class="Extracts-plain-syntax">;</span>

<span class="Extracts-identifier-syntax">typedef</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">struct</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_event_t</span><span class="Extracts-plain-syntax"> {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">type</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">win_id</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">val1</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">val2</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">} </span><span class="Extracts-identifier-syntax">i7_mg_event_t</span><span class="Extracts-plain-syntax">;</span>

<span class="Extracts-plain-syntax">#</span><span class="Extracts-identifier-syntax">define</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">I7_MINIGLK_MAX_FILES</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">128</span>
<span class="Extracts-plain-syntax">#</span><span class="Extracts-identifier-syntax">define</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">I7_MINIGLK_MAX_STREAMS</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">128</span>
<span class="Extracts-plain-syntax">#</span><span class="Extracts-identifier-syntax">define</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">I7_MINIGLK_MAX_WINDOWS</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">128</span>
<span class="Extracts-plain-syntax">#</span><span class="Extracts-identifier-syntax">define</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">I7_MINIGLK_RING_BUFFER_SIZE</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">32</span>

<span class="Extracts-identifier-syntax">typedef</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">struct</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">miniglk_data</span><span class="Extracts-plain-syntax"> {</span>
<span class="Extracts-plain-syntax">    /* </span><span class="Extracts-identifier-syntax">streams</span><span class="Extracts-plain-syntax"> */</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_mg_stream_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">I7_MINIGLK_MAX_STREAMS</span><span class="Extracts-plain-syntax">];</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">stdout_stream_id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">stderr_stream_id</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    /* </span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax"> */</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_mg_file_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">I7_MINIGLK_MAX_FILES</span><span class="Extracts-plain-syntax"> + </span><span class="Extracts-constant-syntax">32</span><span class="Extracts-plain-syntax">];</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">no_files</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    /* </span><span class="Extracts-identifier-syntax">windows</span><span class="Extracts-plain-syntax"> */</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_mg_window_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">windows</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">I7_MINIGLK_MAX_WINDOWS</span><span class="Extracts-plain-syntax">];</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">no_windows</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    /* </span><span class="Extracts-identifier-syntax">events</span><span class="Extracts-plain-syntax"> */</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_mg_event_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">events_ring_buffer</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">I7_MINIGLK_RING_BUFFER_SIZE</span><span class="Extracts-plain-syntax">];</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">rb_back</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">rb_front</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">no_line_events</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">} </span><span class="Extracts-identifier-syntax">miniglk_data</span><span class="Extracts-plain-syntax">;</span>

<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_initialise_miniglk_data</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_initialise_miniglk_data</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">malloc</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">sizeof</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">miniglk_data</span><span class="Extracts-plain-syntax">));</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">printf</span><span class="Extracts-plain-syntax">("</span><span class="Extracts-identifier-syntax">Memory</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">allocation</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">failed</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">");</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">exit</span><span class="Extracts-plain-syntax">(1);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">no_files</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">stdout_stream_id</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">stderr_stream_id</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">no_windows</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">rb_back</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">rb_front</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">no_line_events</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. </b>Each process starts with two streams already open for text output: <span class="extract"><span class="Extracts-extract-syntax">stdout</span></span>
and <span class="extract"><span class="Extracts-extract-syntax">stderr</span></span>, and the former is selected as current.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_initialise_miniglk</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_initialise_miniglk</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">for</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">=0; </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">&lt;</span><span class="Extracts-identifier-syntax">I7_MINIGLK_MAX_STREAMS</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">++)</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">] = </span><span class="Extracts-identifier-syntax">i7_mg_new_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_mg_stream_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">stdout_stream</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_mg_new_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">stdout</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">stdout_stream</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">active</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">stdout_stream</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">encode_UTF8</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">stdout_stream_id</span><span class="Extracts-plain-syntax">] = </span><span class="Extracts-identifier-syntax">stdout_stream</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_mg_stream_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">stderr_stream</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_mg_new_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">stderr_stream</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">active</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">stderr_stream</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">encode_UTF8</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">stderr_stream_id</span><span class="Extracts-plain-syntax">] = </span><span class="Extracts-identifier-syntax">stderr_stream</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_set_current</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">stdout_stream_id</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. File-handling.</b></p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_new_file</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_fseek</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">origin</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_ftell</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_fopen</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">mode</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_fclose</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_fputc</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_fgetc</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_new_file</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">no_files</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-identifier-syntax">I7_MINIGLK_MAX_FILES</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Out</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">of</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">no_files</span><span class="Extracts-plain-syntax">++;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">usage</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">name</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">handle</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">leafname</span><span class="Extracts-plain-syntax">[0] = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_fseek</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">origin</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> ((</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) || (</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-identifier-syntax">I7_MINIGLK_MAX_FILES</span><span class="Extracts-plain-syntax">)) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Bad</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">file</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">ID</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">handle</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">File</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">not</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">open</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">fseek</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">handle</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">origin</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_ftell</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> ((</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) || (</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-identifier-syntax">I7_MINIGLK_MAX_FILES</span><span class="Extracts-plain-syntax">)) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Bad</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">file</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">ID</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">handle</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">File</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">not</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">open</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">t</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">ftell</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">handle</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">t</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_fopen</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">mode</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> ((</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) || (</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-identifier-syntax">I7_MINIGLK_MAX_FILES</span><span class="Extracts-plain-syntax">)) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Bad</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">file</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">ID</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">handle</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">File</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">already</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">open</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">c_mode</span><span class="Extracts-plain-syntax"> = "</span><span class="Extracts-identifier-syntax">r</span><span class="Extracts-plain-syntax">";</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">switch</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">mode</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_filemode_Write</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">c_mode</span><span class="Extracts-plain-syntax"> = "</span><span class="Extracts-identifier-syntax">w</span><span class="Extracts-plain-syntax">"; </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_filemode_Read</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">c_mode</span><span class="Extracts-plain-syntax"> = "</span><span class="Extracts-identifier-syntax">r</span><span class="Extracts-plain-syntax">"; </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_filemode_ReadWrite</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">c_mode</span><span class="Extracts-plain-syntax"> = "</span><span class="Extracts-identifier-syntax">r</span><span class="Extracts-plain-syntax">+"; </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_filemode_WriteAppend</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">c_mode</span><span class="Extracts-plain-syntax"> = "</span><span class="Extracts-identifier-syntax">r</span><span class="Extracts-plain-syntax">+"; </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">FILE</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">h</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">fopen</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">leafname</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">c_mode</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">h</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">handle</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">h</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">mode</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">i7_filemode_WriteAppend</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">i7_mg_fseek</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">SEEK_END</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_fclose</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> ((</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) || (</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-identifier-syntax">I7_MINIGLK_MAX_FILES</span><span class="Extracts-plain-syntax">)) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Bad</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">file</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">ID</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">handle</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">File</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">not</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">open</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">fclose</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">handle</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">handle</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>


<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_fputc</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> ((</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) || (</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-identifier-syntax">I7_MINIGLK_MAX_FILES</span><span class="Extracts-plain-syntax">)) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Bad</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">file</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">ID</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">handle</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">File</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">not</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">open</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">fputc</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">handle</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_fgetc</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> ((</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) || (</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-identifier-syntax">I7_MINIGLK_MAX_FILES</span><span class="Extracts-plain-syntax">)) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Bad</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">file</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">ID</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">handle</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">File</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">not</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">open</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">fgetc</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">handle</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. </b>This allows us to implement <span class="extract"><span class="Extracts-extract-syntax">glk_fileref_create_by_name</span></span> and <span class="extract"><span class="Extracts-extract-syntax">glk_fileref_does_file_exist</span></span>.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_fileref_create_by_name</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">usage</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">name</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_fileref_does_file_exist</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_fileref_create_by_name</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">usage</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">name</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_mg_new_file</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">usage</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">usage</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">name</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">name</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">L</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">leafname</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">for</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">=0; </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">&lt;</span><span class="Extracts-identifier-syntax">I7_MINIGLK_LEAFNAME_LENGTH</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">++) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">L</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">] = </span><span class="Extracts-identifier-syntax">i7_read_byte</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">name</span><span class="Extracts-plain-syntax">+1+</span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">L</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">] == </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">L</span><span class="Extracts-plain-syntax">[127] = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">sprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">L</span><span class="Extracts-plain-syntax"> + </span><span class="Extracts-identifier-syntax">strlen</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">L</span><span class="Extracts-plain-syntax">), ".</span><span class="Extracts-identifier-syntax">glkdata</span><span class="Extracts-plain-syntax">");</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_fileref_does_file_exist</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> ((</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) || (</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-identifier-syntax">I7_MINIGLK_MAX_FILES</span><span class="Extracts-plain-syntax">)) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Bad</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">file</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">ID</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">files</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">handle</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">i7_mg_fopen</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7_filemode_Read</span><span class="Extracts-plain-syntax">)) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_mg_fclose</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">); </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. Streams.</b>These are channels for input/output, carrying bytes (which are usually characters).
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7_mg_stream_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_new_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">FILE</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">F</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">win_id</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_open_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">FILE</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">F</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">win_id</span><span class="Extracts-plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7_mg_stream_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_new_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">FILE</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">F</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">win_id</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_mg_stream_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">to_file</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">F</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">to_file_id</span><span class="Extracts-plain-syntax"> = -1;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">to_memory</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">memory_used</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">memory_capacity</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">write_here_on_closure</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">write_limit</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">previous_id</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">active</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">encode_UTF8</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">char_size</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">4</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">chars_read</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">read_position</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">end_position</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">owned_by_window_id</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">win_id</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">style</span><span class="Extracts-plain-syntax">[0] = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">fixed_pitch</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">composite_style</span><span class="Extracts-plain-syntax">[0] = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_open_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">FILE</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">F</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">win_id</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">for</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">=0; </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">&lt;</span><span class="Extracts-identifier-syntax">I7_MINIGLK_MAX_STREAMS</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">++)</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">active</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">] = </span><span class="Extracts-identifier-syntax">i7_mg_new_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">F</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">win_id</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">active</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">previous_id</span><span class="Extracts-plain-syntax"> =</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">state</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">current_output_stream_ID</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Out</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">of</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">streams</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. </b>This allows us to implement <span class="extract"><span class="Extracts-extract-syntax">glk_stream_open_memory</span></span> and its Unicode-text
analogue <span class="extract"><span class="Extracts-extract-syntax">glk_stream_open_memory_uni</span></span>, and <span class="extract"><span class="Extracts-extract-syntax">glk_stream_open_file</span></span>.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_open_memory</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">buffer</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">len</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">fmode</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_open_memory_uni</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">buffer</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">len</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">fmode</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_open_file</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">fileref</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">usage</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_open_memory</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">buffer</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">len</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">fmode</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">fmode</span><span class="Extracts-plain-syntax"> != </span><span class="Extracts-identifier-syntax">i7_filemode_Write</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Only</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">file</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">mode</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">Write</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">supported</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">not</span><span class="Extracts-plain-syntax"> %</span><span class="Extracts-identifier-syntax">d</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">", </span><span class="Extracts-identifier-syntax">fmode</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_mg_open_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">write_here_on_closure</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">buffer</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">write_limit</span><span class="Extracts-plain-syntax"> = (</span><span class="Extracts-identifier-syntax">size_t</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">len</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">char_size</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">state</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">current_output_stream_ID</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_open_memory_uni</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">buffer</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">len</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">fmode</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">fmode</span><span class="Extracts-plain-syntax"> != </span><span class="Extracts-identifier-syntax">i7_filemode_Write</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Only</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">file</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">mode</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">Write</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">supported</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">not</span><span class="Extracts-plain-syntax"> %</span><span class="Extracts-identifier-syntax">d</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">", </span><span class="Extracts-identifier-syntax">fmode</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_mg_open_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">write_here_on_closure</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">buffer</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">write_limit</span><span class="Extracts-plain-syntax"> = (</span><span class="Extracts-identifier-syntax">size_t</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">len</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">char_size</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">4</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">state</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">current_output_stream_ID</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_open_file</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">fileref</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">usage</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_mg_open_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">to_file_id</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">fileref</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">i7_mg_fopen</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">fileref</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">usage</span><span class="Extracts-plain-syntax">) == </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. </b><span class="extract"><span class="Extracts-extract-syntax">glk_stream_set_position</span></span> and <span class="extract"><span class="Extracts-extract-syntax">glk_stream_get_position</span></span> are essentially for
moving to the start or end of a file, at least for our purposes.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_set_position</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">seekmode</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_get_position</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_set_position</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">seekmode</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> ((</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) || (</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-identifier-syntax">I7_MINIGLK_MAX_STREAMS</span><span class="Extracts-plain-syntax">)) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Stream</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">ID</span><span class="Extracts-plain-syntax"> %</span><span class="Extracts-identifier-syntax">d</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">out</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">of</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">range</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">", </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_mg_stream_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax"> = &amp;(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">]);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">to_file_id</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">origin</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">switch</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">seekmode</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_seekmode_Start</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">origin</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">SEEK_SET</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_seekmode_Current</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">origin</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">SEEK_CUR</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_seekmode_End</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">origin</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">SEEK_END</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">default</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Unknown</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">seekmode</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        }</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_mg_fseek</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">to_file_id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">origin</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    } </span><span class="Extracts-identifier-syntax">else</span><span class="Extracts-plain-syntax"> {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">glk_stream_set_position</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">supported</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">only</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">for</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">file</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">streams</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">");</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_get_position</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> ((</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) || (</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-identifier-syntax">I7_MINIGLK_MAX_STREAMS</span><span class="Extracts-plain-syntax">)) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Stream</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">ID</span><span class="Extracts-plain-syntax"> %</span><span class="Extracts-identifier-syntax">d</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">out</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">of</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">range</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">", </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_mg_stream_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax"> = &amp;(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">]);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">to_file_id</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">i7_mg_ftell</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">to_file_id</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_used</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. </b>Each process has a current stream, and <span class="extract"><span class="Extracts-extract-syntax">glk_stream_get_current</span></span> and
<span class="extract"><span class="Extracts-extract-syntax">glk_stream_set_current</span></span> give access to this.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_get_current</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_set_current</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_get_current</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">state</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">current_output_stream_ID</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_set_current</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> ((</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) || (</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-identifier-syntax">I7_MINIGLK_MAX_STREAMS</span><span class="Extracts-plain-syntax">)) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Stream</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">ID</span><span class="Extracts-plain-syntax"> %</span><span class="Extracts-identifier-syntax">d</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">out</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">of</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">range</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">", </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">state</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">current_output_stream_ID</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP13" class="paragraph-anchor"></a><b>&#167;13. </b>The thing which is "current" about the current stream is that this is where
characters are written to. The following implements <span class="extract"><span class="Extracts-extract-syntax">glk_put_char_stream</span></span>.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_put_to_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">wchar_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_put_char_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">stream_id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">x</span><span class="Extracts-plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_put_to_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">wchar_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_mg_stream_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax"> =</span>
<span class="Extracts-plain-syntax">        &amp;(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">state</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">current_output_stream_ID</span><span class="Extracts-plain-syntax">]);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">receiver</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">fputc</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">stdout</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">receiver</span><span class="Extracts-plain-syntax">)(</span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">composite_style</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_put_char_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">stream_id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">x</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_mg_stream_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax"> = &amp;(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">stream_id</span><span class="Extracts-plain-syntax">]);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">to_file</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">win_id</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">owned_by_window_id</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax"> = -1;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">win_id</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_mg_get_window_rock</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">win_id</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">unsigned</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> = (</span><span class="Extracts-identifier-syntax">unsigned</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">x</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">use_UTF8</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">x200000</span><span class="Extracts-plain-syntax">) { /* </span><span class="Extracts-identifier-syntax">invalid</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">Unicode</span><span class="Extracts-plain-syntax"> */</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">i7_mg_put_to_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">, '?');</span>
<span class="Extracts-plain-syntax">            } </span><span class="Extracts-identifier-syntax">else</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">x10000</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">i7_mg_put_to_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">xF0</span><span class="Extracts-plain-syntax"> + (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &gt;&gt; </span><span class="Extracts-constant-syntax">18</span><span class="Extracts-plain-syntax">));</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">i7_mg_put_to_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">x80</span><span class="Extracts-plain-syntax"> + ((</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &gt;&gt; </span><span class="Extracts-constant-syntax">12</span><span class="Extracts-plain-syntax">) &amp; </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">x3f</span><span class="Extracts-plain-syntax">));</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">i7_mg_put_to_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">x80</span><span class="Extracts-plain-syntax"> + ((</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &gt;&gt; </span><span class="Extracts-constant-syntax">6</span><span class="Extracts-plain-syntax">) &amp; </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">x3f</span><span class="Extracts-plain-syntax">));</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">i7_mg_put_to_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">x80</span><span class="Extracts-plain-syntax"> + (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &amp; </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">x3f</span><span class="Extracts-plain-syntax">));</span>
<span class="Extracts-plain-syntax">            } </span><span class="Extracts-identifier-syntax">else</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">x800</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">i7_mg_put_to_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">xE0</span><span class="Extracts-plain-syntax"> + (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &gt;&gt; </span><span class="Extracts-constant-syntax">12</span><span class="Extracts-plain-syntax">));</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">i7_mg_put_to_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">x80</span><span class="Extracts-plain-syntax"> + ((</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &gt;&gt; </span><span class="Extracts-constant-syntax">6</span><span class="Extracts-plain-syntax">) &amp; </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">x3f</span><span class="Extracts-plain-syntax">));</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">i7_mg_put_to_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">x80</span><span class="Extracts-plain-syntax"> + (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &amp; </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">x3f</span><span class="Extracts-plain-syntax">));</span>
<span class="Extracts-plain-syntax">            } </span><span class="Extracts-identifier-syntax">else</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">x80</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">i7_mg_put_to_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">xC0</span><span class="Extracts-plain-syntax"> + (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &gt;&gt; </span><span class="Extracts-constant-syntax">6</span><span class="Extracts-plain-syntax">));</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">i7_mg_put_to_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">x80</span><span class="Extracts-plain-syntax"> + (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> &amp; </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-identifier-syntax">x3f</span><span class="Extracts-plain-syntax">));</span>
<span class="Extracts-plain-syntax">            } </span><span class="Extracts-identifier-syntax">else</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_put_to_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">, (</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        } </span><span class="Extracts-identifier-syntax">else</span><span class="Extracts-plain-syntax"> {</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">i7_mg_put_to_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">, (</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        }</span>
<span class="Extracts-plain-syntax">    } </span><span class="Extracts-identifier-syntax">else</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">to_file_id</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_mg_fputc</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, (</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">x</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">to_file_id</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">end_position</span><span class="Extracts-plain-syntax">++;</span>
<span class="Extracts-plain-syntax">    } </span><span class="Extracts-identifier-syntax">else</span><span class="Extracts-plain-syntax"> {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_used</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_capacity</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">size_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">needed</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">4</span><span class="Extracts-plain-syntax">*</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_capacity</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">needed</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">needed</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">1024</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">wchar_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">new_data</span><span class="Extracts-plain-syntax"> = (</span><span class="Extracts-identifier-syntax">wchar_t</span><span class="Extracts-plain-syntax"> *) </span><span class="Extracts-identifier-syntax">calloc</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">needed</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">sizeof</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">wchar_t</span><span class="Extracts-plain-syntax">));</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">new_data</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Out</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">of</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">memory</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">            }</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">for</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">size_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">=0; </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">&lt;</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_used</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">++) </span><span class="Extracts-identifier-syntax">new_data</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">] = </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">to_memory</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">];</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">free</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">to_memory</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">to_memory</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">new_data</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        }</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">to_memory</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_used</span><span class="Extracts-plain-syntax">++] = (</span><span class="Extracts-identifier-syntax">wchar_t</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">x</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP14" class="paragraph-anchor"></a><b>&#167;14. </b>Note that the current stream is irrelevant to reading characters, where we
have to specify exactly which stream is intended. Here's <span class="extract"><span class="Extracts-extract-syntax">glk_get_char_stream</span></span>:
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_get_char_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">stream_id</span><span class="Extracts-plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_get_char_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">stream_id</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_mg_stream_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax"> = &amp;(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">stream_id</span><span class="Extracts-plain-syntax">]);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">to_file_id</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">chars_read</span><span class="Extracts-plain-syntax">++;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_fgetc</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">to_file_id</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP15" class="paragraph-anchor"></a><b>&#167;15. </b>And finally <span class="extract"><span class="Extracts-extract-syntax">glk_stream_close</span></span>, which is far from being an empty courtesy:
we may have to close a file on disc, or we may have to copy a memory buffer into
process memory.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_close</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">result</span><span class="Extracts-plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_close</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">result</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> ((</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) || (</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-identifier-syntax">I7_MINIGLK_MAX_STREAMS</span><span class="Extracts-plain-syntax">)) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Stream</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">ID</span><span class="Extracts-plain-syntax"> %</span><span class="Extracts-identifier-syntax">d</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">out</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">of</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">range</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">", </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) { </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Cannot</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">close</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">stdout</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">); }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">) { </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Cannot</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">close</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">); }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_mg_stream_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax"> = &amp;(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">]);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">active</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Stream</span><span class="Extracts-plain-syntax"> %</span><span class="Extracts-identifier-syntax">d</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">already</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">closed</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">", </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">state</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">current_output_stream_ID</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">)</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">state</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">current_output_stream_ID</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">previous_id</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">write_here_on_closure</span><span class="Extracts-plain-syntax"> != </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">char_size</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-constant-syntax">4</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">for</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">size_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">write_limit</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">++)</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_used</span><span class="Extracts-plain-syntax">)</span>
<span class="Extracts-plain-syntax">                    </span><span class="Extracts-identifier-syntax">i7_write_word</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">write_here_on_closure</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">to_memory</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">]);</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">else</span>
<span class="Extracts-plain-syntax">                    </span><span class="Extracts-identifier-syntax">i7_write_word</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">write_here_on_closure</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        } </span><span class="Extracts-identifier-syntax">else</span><span class="Extracts-plain-syntax"> {</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">for</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">size_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">write_limit</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">++)</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_used</span><span class="Extracts-plain-syntax">)</span>
<span class="Extracts-plain-syntax">                    </span><span class="Extracts-identifier-syntax">i7_write_byte</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">write_here_on_closure</span><span class="Extracts-plain-syntax"> + </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">to_memory</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">]);</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">else</span>
<span class="Extracts-plain-syntax">                    </span><span class="Extracts-identifier-syntax">i7_write_byte</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">write_here_on_closure</span><span class="Extracts-plain-syntax"> + </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        }</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">result</span><span class="Extracts-plain-syntax"> == -1) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_push</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">chars_read</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_push</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_used</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    } </span><span class="Extracts-identifier-syntax">else</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">result</span><span class="Extracts-plain-syntax"> != </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_write_word</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">result</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">chars_read</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_write_word</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">result</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_used</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">to_file_id</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">i7_mg_fclose</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">to_file_id</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">active</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_used</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP16" class="paragraph-anchor"></a><b>&#167;16. Windows.</b>Even a proper Glk implementation isn't presenting any kind of window manager in
the style of Xerox or early Macs: these windows are (borderless, invisible)
rectangles on a plain text grid.
</p>

<p class="commentary">And in this miniglk, a window is really just a receptacle for a stream of text.
We make no attempt to model how multiple windows might sit, because we're
assuming that either (i) we are being used for a command-line console app which
doesn't treat the Terminal window as two-dimensional, or (ii) we are being linked
into some bigger GUI app which is going to handle everything visual in its own
way anyway.
</p>

<p class="commentary">Note that we shamelessly claim that all windows are 80 x 8 characters.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_window_open</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">split</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">method</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">size</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">wintype</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_set_window</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_get_window_rock</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_window_get_size</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">a1</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">a2</span><span class="Extracts-plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_window_open</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">split</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">method</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">size</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">wintype</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">no_windows</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-constant-syntax">128</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Out</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">of</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">windows</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">no_windows</span><span class="Extracts-plain-syntax">++;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">windows</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">type</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">wintype</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">windows</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">stream_id</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_mg_open_stream</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">stdout</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">windows</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_set_window</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> ((</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) || (</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">no_windows</span><span class="Extracts-plain-syntax">)) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Window</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">ID</span><span class="Extracts-plain-syntax"> %</span><span class="Extracts-identifier-syntax">d</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">out</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">of</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">range</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">", </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_miniglk_stream_set_current</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">windows</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">stream_id</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_get_window_rock</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> ((</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) || (</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax"> &gt;= </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">no_windows</span><span class="Extracts-plain-syntax">)) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">Window</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">ID</span><span class="Extracts-plain-syntax"> %</span><span class="Extracts-identifier-syntax">d</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">out</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">of</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">range</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">", </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">windows</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">].</span><span class="Extracts-identifier-syntax">rock</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_window_get_size</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">id</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">a1</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">a2</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">a1</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">i7_write_word</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a1</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">80</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">a2</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">i7_write_word</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">a2</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">8</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP17" class="paragraph-anchor"></a><b>&#167;17. Events.</b>Pending events are stored in a ring buffer, where the valid pending events are
those between the <span class="extract"><span class="Extracts-extract-syntax">rb_back</span></span> and <span class="extract"><span class="Extracts-extract-syntax">rb_front</span></span> markers, modulo <span class="extract"><span class="Extracts-extract-syntax">I7_MINIGLK_RING_BUFFER_SIZE</span></span>.
(In practice, this is more than we need for the very simple use that the standard
I7 kits make of events. Still, it does no harm.)
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_add_event_to_buffer</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7_mg_event_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">i7_mg_event_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">i7_mg_get_event_from_buffer</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mg_add_event_to_buffer</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7_mg_event_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">events_ring_buffer</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">rb_front</span><span class="Extracts-plain-syntax">] = </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">rb_front</span><span class="Extracts-plain-syntax">++;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">rb_front</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">I7_MINIGLK_RING_BUFFER_SIZE</span><span class="Extracts-plain-syntax">)</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">rb_front</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">i7_mg_event_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">i7_mg_get_event_from_buffer</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">rb_front</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">rb_back</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_mg_event_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax"> = &amp;(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">events_ring_buffer</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">rb_back</span><span class="Extracts-plain-syntax">]);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">rb_back</span><span class="Extracts-plain-syntax">++;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">rb_back</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">I7_MINIGLK_RING_BUFFER_SIZE</span><span class="Extracts-plain-syntax">)</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">rb_back</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP18" class="paragraph-anchor"></a><b>&#167;18. </b>That enables <span class="extract"><span class="Extracts-extract-syntax">glk_select</span></span>, an operation by which the caller can choose to
pull an event from the buffer and (optionally) copy its data ihto process
memory.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_select</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">structure</span><span class="Extracts-plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_select</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">structure</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_mg_event_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_mg_get_event_from_buffer</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stderr</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">No</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">events</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">available</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">to</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">select</span><span class="Extracts-plain-syntax">\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">i7_fatal_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">structure</span><span class="Extracts-plain-syntax"> == -1) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_push</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">type</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_push</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">win_id</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_push</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">val1</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">i7_push</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">val2</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    } </span><span class="Extracts-identifier-syntax">else</span><span class="Extracts-plain-syntax"> {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">structure</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">i7_write_word</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">structure</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">type</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">i7_write_word</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">structure</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">win_id</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">i7_write_word</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">structure</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">2</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">val1</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">i7_write_word</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">structure</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">3</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">val2</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">        }</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP19" class="paragraph-anchor"></a><b>&#167;19. </b>And also <span class="extract"><span class="Extracts-extract-syntax">glk_request_line_event</span></span>. This asks the process's sender function to
compose a command (terminated by 0 or a newline), then makes that it into a
line event and pushes it to the event buffer. The caller can then use <span class="extract"><span class="Extracts-extract-syntax">glk_select</span></span>
to find out what the command was.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_request_line_event</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">window_id</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">buffer</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">max_len</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">init_len</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_request_line_event_uni</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">window_id</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">buffer</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">max_len</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">init_len</span><span class="Extracts-plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.h.</li></ul>
<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_request_line_event</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">window_id</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">buffer</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">max_len</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">init_len</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_mg_event_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">type</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_evtype_LineInput</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">win_id</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">window_id</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">val1</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">val2</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">wchar_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">init_len</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">sender</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">i7_benign_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">s</span><span class="Extracts-plain-syntax"> = (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">sender</span><span class="Extracts-plain-syntax">)(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">send_count</span><span class="Extracts-plain-syntax">++);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">while</span><span class="Extracts-plain-syntax"> (1) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">s</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">++];</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> ((</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">EOF</span><span class="Extracts-plain-syntax">) || (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) || (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> == '\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">') || (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> == '\</span><span class="Extracts-identifier-syntax">r</span><span class="Extracts-plain-syntax">')) </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-identifier-syntax">max_len</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">i7_write_byte</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">buffer</span><span class="Extracts-plain-syntax"> + </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">++, </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-identifier-syntax">max_len</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">i7_write_byte</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">buffer</span><span class="Extracts-plain-syntax"> + </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">else</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_write_byte</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">buffer</span><span class="Extracts-plain-syntax"> + </span><span class="Extracts-identifier-syntax">max_len</span><span class="Extracts-plain-syntax">-1, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">val1</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_mg_add_event_to_buffer</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">no_line_events</span><span class="Extracts-plain-syntax">++ == </span><span class="Extracts-constant-syntax">1000</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stdout</span><span class="Extracts-plain-syntax">, "[</span><span class="Extracts-identifier-syntax">Too</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">many</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">line</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">events</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">terminating</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">to</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">prevent</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">hang</span><span class="Extracts-plain-syntax">]\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">");</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">exit</span><span class="Extracts-plain-syntax">(0);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>

<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_miniglk_request_line_event_uni</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">window_id</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">buffer</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">max_len</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">init_len</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_mg_event_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">type</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">i7_evtype_LineInput</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">win_id</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">window_id</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">val1</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">val2</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">wchar_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">init_len</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">sender</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">NULL</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">i7_benign_exit</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">char</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">s</span><span class="Extracts-plain-syntax"> = (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">sender</span><span class="Extracts-plain-syntax">)(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">send_count</span><span class="Extracts-plain-syntax">++);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">while</span><span class="Extracts-plain-syntax"> (1) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">s</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">++];</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> ((</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-identifier-syntax">EOF</span><span class="Extracts-plain-syntax">) || (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">) || (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> == '\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">') || (</span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax"> == '\</span><span class="Extracts-identifier-syntax">r</span><span class="Extracts-plain-syntax">')) </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-identifier-syntax">max_len</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">i7_write_word</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">buffer</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">++, </span><span class="Extracts-identifier-syntax">c</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax"> &lt; </span><span class="Extracts-identifier-syntax">max_len</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">i7_write_word</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">buffer</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">else</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_write_word</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">buffer</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">max_len</span><span class="Extracts-plain-syntax">-1, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">val1</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">pos</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_mg_add_event_to_buffer</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">e</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">no_line_events</span><span class="Extracts-plain-syntax">++ == </span><span class="Extracts-constant-syntax">1000</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">fprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">stdout</span><span class="Extracts-plain-syntax">, "[</span><span class="Extracts-identifier-syntax">Too</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">many</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">line</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">events</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">terminating</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">to</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">prevent</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">hang</span><span class="Extracts-plain-syntax">]\</span><span class="Extracts-identifier-syntax">n</span><span class="Extracts-plain-syntax">");</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">exit</span><span class="Extracts-plain-syntax">(0);</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">return</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<p class="commentary firstcommentary"><a id="SP20" class="paragraph-anchor"></a><b>&#167;20. Styling.</b>This happens outside of miniglk. Glk does have a concept of text styles, but one
which is difficult to marry to CSS-esque styles in the way we might want here.
So we provide this additional styling functionality outside of the Glk specification.
When <span class="extract"><span class="Extracts-extract-syntax">which</span></span> is 1, we're essentially emulating Inform 6's <span class="extract"><span class="Extracts-extract-syntax">font</span></span> statement; when
it is 2, we're emulation <span class="extract"><span class="Extracts-extract-syntax">style</span></span>, though an enhanced version capable of more than
the three built-in styles <span class="extract"><span class="Extracts-extract-syntax">bold</span></span>, <span class="extract"><span class="Extracts-extract-syntax">italic</span></span> and <span class="extract"><span class="Extracts-extract-syntax">reverse</span></span>.
</p>

<pre class="Extracts-displayed-code all-displayed-code code-font">
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_fn_TEXT_TY_CharacterLength</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mgl_local_txt</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mgl_local_ch</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mgl_local_i</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mgl_local_dsize</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mgl_local_p</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mgl_local_cp</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mgl_local_r</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_fn_BlkValueRead</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mgl_local_from</span><span class="Extracts-plain-syntax">,</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mgl_local_pos</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mgl_local_do_not_indirect</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-identifier-syntax">void</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_default_stylist</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">i7process_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">which</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i7word_t</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">what</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">i7_mg_stream_t</span><span class="Extracts-plain-syntax"> *</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax"> =</span>
<span class="Extracts-plain-syntax">        &amp;(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">miniglk</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">memory_streams</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">state</span><span class="Extracts-plain-syntax">.</span><span class="Extracts-identifier-syntax">current_output_stream_ID</span><span class="Extracts-plain-syntax">]);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">which</span><span class="Extracts-plain-syntax"> == </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">fixed_pitch</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-identifier-syntax">what</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">    } </span><span class="Extracts-identifier-syntax">else</span><span class="Extracts-plain-syntax"> {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">style</span><span class="Extracts-plain-syntax">[0] = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">switch</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">what</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">1</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">sprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">style</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">bold</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">2</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">sprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">style</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">italic</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">case</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-constant-syntax">3</span><span class="Extracts-plain-syntax">: </span><span class="Extracts-identifier-syntax">sprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">style</span><span class="Extracts-plain-syntax">, "</span><span class="Extracts-identifier-syntax">reverse</span><span class="Extracts-plain-syntax">"); </span><span class="Extracts-identifier-syntax">break</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">default</span><span class="Extracts-plain-syntax">: {</span>
<span class="Extracts-plain-syntax">                #</span><span class="Extracts-identifier-syntax">ifdef</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i7_mgl_BASICINFORMKIT</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">L</span><span class="Extracts-plain-syntax"> =</span>
<span class="Extracts-plain-syntax">                    </span><span class="Extracts-identifier-syntax">i7_fn_TEXT_TY_CharacterLength</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">what</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">L</span><span class="Extracts-plain-syntax"> &gt; </span><span class="Extracts-constant-syntax">127</span><span class="Extracts-plain-syntax">) </span><span class="Extracts-identifier-syntax">L</span><span class="Extracts-plain-syntax"> = </span><span class="Extracts-constant-syntax">127</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">for</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">int</span><span class="Extracts-plain-syntax"> </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">=0; </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">&lt;</span><span class="Extracts-identifier-syntax">L</span><span class="Extracts-plain-syntax">; </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">++) </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">style</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">] =</span>
<span class="Extracts-plain-syntax">                    </span><span class="Extracts-identifier-syntax">i7_fn_BlkValueRead</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">proc</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">what</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-identifier-syntax">i</span><span class="Extracts-plain-syntax">, </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">                </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">style</span><span class="Extracts-plain-syntax">[</span><span class="Extracts-identifier-syntax">L</span><span class="Extracts-plain-syntax">] = </span><span class="Extracts-constant-syntax">0</span><span class="Extracts-plain-syntax">;</span>
<span class="Extracts-plain-syntax">                #</span><span class="Extracts-identifier-syntax">endif</span>
<span class="Extracts-plain-syntax">            }</span>
<span class="Extracts-plain-syntax">        }</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">sprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">composite_style</span><span class="Extracts-plain-syntax">, "%</span><span class="Extracts-identifier-syntax">s</span><span class="Extracts-plain-syntax">", </span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">style</span><span class="Extracts-plain-syntax">);</span>
<span class="Extracts-plain-syntax">    </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">fixed_pitch</span><span class="Extracts-plain-syntax">) {</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">if</span><span class="Extracts-plain-syntax"> (</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">composite_style</span><span class="Extracts-plain-syntax">[0])</span>
<span class="Extracts-plain-syntax">            </span><span class="Extracts-identifier-syntax">sprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">composite_style</span><span class="Extracts-plain-syntax"> + </span><span class="Extracts-identifier-syntax">strlen</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">composite_style</span><span class="Extracts-plain-syntax">), ",");</span>
<span class="Extracts-plain-syntax">        </span><span class="Extracts-identifier-syntax">sprintf</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">composite_style</span><span class="Extracts-plain-syntax"> + </span><span class="Extracts-identifier-syntax">strlen</span><span class="Extracts-plain-syntax">(</span><span class="Extracts-identifier-syntax">S</span><span class="Extracts-plain-syntax">-&gt;</span><span class="Extracts-identifier-syntax">composite_style</span><span class="Extracts-plain-syntax">), "</span><span class="Extracts-identifier-syntax">fixedpitch</span><span class="Extracts-plain-syntax">");</span>
<span class="Extracts-plain-syntax">    }</span>
<span class="Extracts-plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This is part of the extract file inform7_clib.c.</li></ul>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="5-cim.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-fm.html">1</a></li><li class="progresschapter"><a href="2-cg.html">2</a></li><li class="progresschapter"><a href="3-fti.html">3</a></li><li class="progresschapter"><a href="4-fi6.html">4</a></li><li class="progresscurrentchapter">5</li><li class="progresssection"><a href="5-fnc.html">fnc</a></li><li class="progresssection"><a href="5-cnm.html">cnm</a></li><li class="progresssection"><a href="5-crf.html">crf</a></li><li class="progresssection"><a href="5-cgv.html">cgv</a></li><li class="progresssection"><a href="5-cmm.html">cmm</a></li><li class="progresssection"><a href="5-cas.html">cas</a></li><li class="progresssection"><a href="5-car.html">car</a></li><li class="progresssection"><a href="5-cpc.html">cpc</a></li><li class="progresssection"><a href="5-ccn.html">ccn</a></li><li class="progresssection"><a href="5-clt.html">clt</a></li><li class="progresssection"><a href="5-com.html">com</a></li><li class="progresssection"><a href="5-cfm.html">cfm</a></li><li class="progresssection"><a href="5-cim.html">cim</a></li><li class="progresscurrent">cmn</li><li class="progresssection"><a href="5-cuf.html">cuf</a></li><li class="progressnext"><a href="5-cuf.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

